package com.zhentao.studyim.dto;

import com.zhentao.studyim.entity.FriendRequest;
import com.zhentao.studyim.entity.User;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 好友申请DTO，包含完整的用户信息
 */
@Data
public class FriendRequestDto {
    
    private Long id;
    private Long fromUserId;
    private Long toUserId;
    private String message;
    private String status;
    private LocalDateTime createTime;
    private LocalDateTime updateTime;
    
    // 发送者用户信息
    private User fromUser;
    
    // 接收者用户信息
    private User toUser;
    
    /**
     * 从FriendRequest实体创建DTO
     */
    public static FriendRequestDto fromEntity(FriendRequest friendRequest, User fromUser, User toUser) {
        FriendRequestDto dto = new FriendRequestDto();
        dto.setId(friendRequest.getId());
        dto.setFromUserId(friendRequest.getFromUserId());
        dto.setToUserId(friendRequest.getToUserId());
        dto.setMessage(friendRequest.getMessage());
        dto.setStatus(friendRequest.getStatus().name());
        dto.setCreateTime(friendRequest.getCreateTime());
        dto.setUpdateTime(friendRequest.getUpdateTime());
        dto.setFromUser(fromUser);
        dto.setToUser(toUser);
        return dto;
    }
} 